package com.linln.modules.system.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.linln.common.enums.StatusEnum;
import com.linln.common.utils.StatusUtil;
import com.linln.component.excel.annotation.Excel;
import com.linln.component.excel.enums.ExcelType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author 小懒虫
 * @date 2018/8/14
 */
@Data
@Entity
@Table(name = "pcs_project")
@ToString(exclude = {"dept", "roles"})
@EqualsAndHashCode(exclude = {"dept", "roles"})
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update pcs_project" + StatusUtil.SLICE_DELETE)
@Where(clause = StatusUtil.NOT_DELETE)
@Excel("项目（商品）")
public class Project implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Excel(value = "ID", type = ExcelType.EXPORT)
    private Long id;

    @CreatedDate
    @JsonFormat(pattern = "yyyy-MM-dd H:m:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd H:m:ss")
    @Excel("创建时间")
    private Date createTime;

    @LastModifiedDate
    @Excel("更新时间")
    private Date updateTime;

    @JsonIgnore
    private Long createUser;

    @JsonIgnore
    private Long updateUser;

    @Excel("名称")
    private String title;

    @Excel("合同模板ID")
    private Long contractTplId;

    @Excel("0 不需签订合同 1 需要签订合同")
    private Byte isNeedSignContract;

    @Excel("护工当前服务人数限制")
    private Integer numberLimit;

    @Excel("小时单价")
    private Double price;

    @Excel("服务说明")
    @Lob
    private String content;

    @Excel("审核状态 -1 待提交 0 待审核 1 已通过 2 已驳回")
    private Integer verifyStatus;

    @Excel("备注/驳回理由")
    private String remark;

    @Excel("项目图片")
    private String img;

    @Excel("1 陪护 2 陪诊 3 陪检")
    private String type;

    @Excel("护理公司ID")
    private Long companyId;

    private Byte status = StatusEnum.OK.getCode();

    @Excel("公司名称")
    @Transient
    private String companyName;

    @Transient
    List<ProjectStage> projectStageList = new ArrayList<>();

    @Transient
    //删除的阶段类型id
    String removeStageId = "";
    private Integer isWl;//是否为五类人员0否 1是
    private Double  commissionRate;
}
